package com.daotingli.backendprograms.Repository.Login;

import com.daotingli.backendprograms.DB.SpringDB;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.HashMap;
import java.util.Map;
import java.util.List;
@Component
public class LoginRepository {

    @Autowired
    private SpringDB springDB;
    public Map login(String username, String password,  String identity)
    {
        JdbcTemplate jdbcTemplate=springDB.getJdbcTemplate();
        String sql="select * from t_user where username=? and password=? and identity=? and userstate=?";
        List list=jdbcTemplate.queryForList(sql,username,password,identity,0);
        Map map=new HashMap();

        if(list.size()>0)
            {
                map.put("code",200);
                map.put("msg","登录成功");
                map.put("data",list);
            }
        else
            {
                map.put("code",400);
                map.put("msg","登录失败");
                map.put("data",list);
            }
        return map;
    }
}
